package com.baseweb.webadmin.core.model.mapper;

import com.baseweb.webadmin.core.model.Sql.SqlProvider;
import com.baseweb.webadmin.core.model.bvo.ByUserBizProductBvo;
import com.baseweb.webadmin.core.model.pojo.ByUserBizProduct;
import com.baseweb.webadmin.core.model.pojo.ByUserBizProductExample;
import java.util.List;

import com.baseweb.webadmin.core.model.pojo.User;
import org.apache.ibatis.annotations.*;
import org.joda.time.DateTime;
import org.springframework.web.bind.annotation.RequestMapping;

public interface ByUserBizProductMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_biz_product
     *
     * @mbggenerated Sat Feb 18 10:15:04 CST 2017
     */
    int countByExample(ByUserBizProductExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_biz_product
     *
     * @mbggenerated Sat Feb 18 10:15:04 CST 2017
     */
    int deleteByExample(ByUserBizProductExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_biz_product
     *
     * @mbggenerated Sat Feb 18 10:15:04 CST 2017
     */
    @Delete({
        "delete from by_user_biz_product",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_biz_product
     *
     * @mbggenerated Sat Feb 18 10:15:04 CST 2017
     */
    @Insert({
        "insert into by_user_biz_product (user_id, product_type, ",
        "channel_id, name, ",
        "img_url, original_price, ",
        "current_price, create_time, ",
        "update_time, ",
        "coins, descn, status, ",
        "unit, deposit)",
        "values (#{userId,jdbcType=INTEGER}, #{productType,jdbcType=INTEGER}, ",
        "#{channelId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ",
        "#{imgUrl,jdbcType=VARCHAR}, #{originalPrice,jdbcType=DECIMAL}, ",
        "#{currentPrice,jdbcType=DECIMAL}, #{createTime,jdbcType=TIMESTAMP,typeHandler=com.baseweb.mybatis.typehandler.JodaDateTime2TimestampTypeHandler}, ",
        "#{updateTime,jdbcType=TIMESTAMP,typeHandler=com.baseweb.mybatis.typehandler.JodaDateTime2TimestampTypeHandler}, ",
        "#{coins,jdbcType=INTEGER}, #{descn,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ",
        "#{unit,jdbcType=VARCHAR}, #{deposit,jdbcType=DECIMAL})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(ByUserBizProduct record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_biz_product
     *
     * @mbggenerated Sat Feb 18 10:15:04 CST 2017
     */
    int insertSelective(ByUserBizProduct record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_biz_product
     *
     * @mbggenerated Sat Feb 18 10:15:04 CST 2017
     */
    List<ByUserBizProduct> selectByExample(ByUserBizProductExample example);

    @Select({
        "select",
            "*",
            "from by_user_biz_product p ",
            "left join user u on u.id = p.user_id ",
            "where 1=1 ",
            "${username}"
    })
    public List<ByUserBizProductBvo> selectProductVoListBySQL(User user);

    /**
     * 报价列表
     * @param userId
     * @param start
     * @param offset
     * @return
     */
    @SelectProvider(type = SqlProvider.class,method = "selectProductPageSql")
    @ResultMap("productUnin")
    public List<ByUserBizProductBvo> selectProductVoListByPage(@Param("userId") Integer userId, @Param("userName") String userName, @Param("userMobile") String userMobile, @Param("userChannel") String userChannel, @Param("keyword") String keyword,
                                                               @Param("auditType") Integer auditType, @Param("status") Integer status, @Param("startTime") String startTime, @Param("endTime") String endTime,
                                                               @Param("province") String province, @Param("city") String city, @Param("county") String county, @Param("start")Integer start, @Param("offset")Integer offset);

    @SelectProvider(type = SqlProvider.class, method = "selectProductCountSql")
    public Integer selectProductVoCount(@Param("userId") Integer userId, @Param("userName") String userName, @Param("userMobile") String userMobile, @Param("userChannel") String userChannel, @Param("keyword") String keyword,
                                        @Param("auditType") Integer auditType, @Param("status") Integer status, @Param("startTime") String startTime, @Param("endTime") String endTime,
                                        @Param("province") String province, @Param("city") String city, @Param("county") String county);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_biz_product
     *
     * @mbggenerated Sat Feb 18 10:15:04 CST 2017
     */
    @Select({
        "select",
        "id, user_id, product_type, channel_id, name, img_url, original_price, current_price, ",
        "create_time, update_time, coins, descn, status, unit, deposit, audit_count",
        "from by_user_biz_product",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    ByUserBizProduct selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_biz_product
     *
     * @mbggenerated Sat Feb 18 10:15:04 CST 2017
     */
    int updateByExampleSelective(@Param("record") ByUserBizProduct record, @Param("example") ByUserBizProductExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_biz_product
     *
     * @mbggenerated Sat Feb 18 10:15:04 CST 2017
     */
    int updateByExample(@Param("record") ByUserBizProduct record, @Param("example") ByUserBizProductExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_biz_product
     *
     * @mbggenerated Sat Feb 18 10:15:04 CST 2017
     */
    int updateByPrimaryKeySelective(ByUserBizProduct record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_biz_product
     *
     * @mbggenerated Sat Feb 18 10:15:04 CST 2017
     */
    @Update({
        "update by_user_biz_product",
        "set user_id = #{userId,jdbcType=INTEGER},",
          "product_type = #{productType,jdbcType=INTEGER},",
          "channel_id = #{channelId,jdbcType=INTEGER},",
          "name = #{name,jdbcType=VARCHAR},",
          "img_url = #{imgUrl,jdbcType=VARCHAR},",
          "original_price = #{originalPrice,jdbcType=DECIMAL},",
          "current_price = #{currentPrice,jdbcType=DECIMAL},",
          "create_time = #{createTime,jdbcType=TIMESTAMP,typeHandler=com.baseweb.mybatis.typehandler.JodaDateTime2TimestampTypeHandler},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP,typeHandler=com.baseweb.mybatis.typehandler.JodaDateTime2TimestampTypeHandler},",
          "coins = #{coins,jdbcType=INTEGER},",
          "descn = #{descn,jdbcType=VARCHAR},",
          "status = #{status,jdbcType=INTEGER},",
          "unit = #{unit,jdbcType=VARCHAR},",
          "audit_count = #{auditCount, jdbcType=INTEGER},",
          "deposit = #{deposit,jdbcType=DECIMAL}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(ByUserBizProduct record);
}